<?php
/**
 * 图片库控制器
 */
namespace Admin\Controller;
use Think\Controller;
class GalleryController extends InitController {

	// 图片上传
	public function uploadImg(){
		$info = $this->upload('image');

		$img = $info['savepath'] . $info['savename'];
		// 记录到商品图库表
		$galleryModel =  M('GoodsGallery');
		if (!$galleryModel->where(array('key'=>$info['md5']))->count()) {
			$data['key'] = $info['md5'];
			$data['img'] = $img;
			$data['createtime'] = NOW_TIME;
			$data['admin_id'] = session('uid');
			$galleryModel->add($data);
		}
		
		$this->ajaxReturn(array('error'=>0,'imgUrl'=>$img));
	}
	
}